#!/usr/bin/python3

# 列表推导式

vec = [2, 8, 6]
print(vec)

nec_vec = [x*2 for x in vec]
print(nec_vec)

nec_vec = [[x*2, x**2] for x in vec]
print(nec_vec)

# 过滤器，将小于7的拎出来减2
nec_vec = [x-2 for x in vec if x < 7] 
print(nec_vec)

vec1 = [2, 4, 6]
vec2 = [4, 3, -9]

new_vec = [x*y for x in vec1 for y in vec2] #类似与两个for循环嵌套，x在外层y在内层
print(new_vec)

print("------------------------")


freshfruit = ['  banana', '  loganberry ', 'passion fruit  ']
#  strip() 方法用于移除字符串头尾指定的字符（默认为空格）或字符序列
new_freshfruit = [var.strip() for var in freshfruit]
print(new_freshfruit)
print("------------------------")

# del 语句可以从一个列表中依索引来删除一个元素

a = [-1, 1, 66.25, 333, 333, 1234.5]
print(a)

del a[0]
print(a)

del a[2:4]
print(a)

print("------------------------")






